package com.liuheng.spzx.user.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
@Slf4j
public class EmailUtil {
    public static String sendMail(JavaMailSender jms,String username) {
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        mainMessage.setFrom("2100981240@qq.com");
        mainMessage.setTo(username+"@"+"qq.com");
        mainMessage.setSubject("邮箱验证");
        String s = ValidateCodeUtils.generateValidateCode4String(4);
        log.info("验证码是：{}",s);
        String msg = "你好" +username+ "的验证码是:"+s;
        mainMessage.setText(msg);
        // 注意：在测试环境下，如果不想真正发送邮件，还可以考虑使用Mockito等工具来模拟邮件发送行为
        jms.send(mainMessage);
        return s;
    }
}
